| API Documentation |  |

- MAIN PAGE
- NAMESPACES
- CLASSES

BufferCast.h
1 // BufferCast.h
3 //
5
6 namespace nkMemory
7 {
16 template <typename T = unsigned char>
17 class BufferCast
18 {
19 public :
20
21 // Constructors, destructor
25 BufferCast () noexcept = default ;
32 BufferCast (unsigned long long size) noexcept ;
39 BufferCast (T* data, unsigned long long size) noexcept ;
46 BufferCast (const Buffer& buffer) noexcept ;
53 BufferCast (Buffer&& buffer) noexcept ;
60 BufferCast (const BufferCast& cast) noexcept ;
67 BufferCast (BufferCast&& cast) noexcept ;
75 template <typename U = T>
76 BufferCast (std::enable_if_t<!std::is_class_v<U>, const Buffer&> buffer) noexcept ;
82 ~BufferCast () ;
83
84 public :
85
86 // Getters
90 T* getData () const ;
94 unsigned long long getSize () const ;
98 unsigned long long getByteSize () const
102 bool empty () const ;
106 T& front () ;
110 const T& front () const ;
114 T& back () ;
118 const T& back () const ;
122 T* begin () ;
126 const T* begin () const ;
130 T* end () ;
134 const T* end () const ;
135
136 public :
137
138 // Management
142 BufferCast<T>& clear () ;
149 BufferCast<T>& resize (unsigned long long size) ;
157 T& append (const T& value) ;
165 template <typename U = T>
166 typename std::enable_if_t<std::is_class_v<U>, T&>
167 append (T&& value) ;
175 BufferCast<T>& erase (unsigned long long index, unsigned long long count = 1ull)
184 Buffer relinquishBufferOwnership () ;
192 typename
193 BufferCastDataDescriptor<T> relinquishDataOwnership () ;
194
195 public :
196
197 // Operators
204 T& operator[] (unsigned long long index) ;
211 const T& operator[] (unsigned long long index) const ;
218 BufferCast<T>& operator= (const BufferCast<T>& other) noexcept ;
225 template <typename U = T>
226 std::enable_if_t<!std::is_class_v<U> || std::is_move_assignable_v<U>, BufferCast<T>&>
227 operator= (BufferCast<T>&& other) noexcept ;
228
229 public :
230
231 // Templated constructors
237 template <std::size_t S>
238 BufferCast (const std::array<T, S>& array) noexcept ;
239
245 template <typename U, std::size_t S>
246 BufferCast (const std::array<U, S>& array) noexcept ;
247
253 BufferCast (const std::vector<T>& vec) noexcept ;
254
260 template <typename U>
261 BufferCast (const std::vector<U>& vec) noexcept ;
267 BufferCast (std::initializer_list<T> args) noexcept ;
273 BufferCast (std::initializer_list<U> args) noexcept ;
274 } ;
275 }
nkMemory::BufferCast::getSize
unsigned long long getSize() const
nkMemory::BufferCast::append
T & append(const T &value)
nkMemory::BufferCast::getByteSize
unsigned long long getByteSize() const bool empty() const
nkMemory::BufferCast::back
T & back()
nkMemory::BufferCast::clear
BufferCast< T > & clear()
nkMemory::BufferCast::getData
T * getData() const
nkMemory::BufferCast::relinquishDataOwnership
BufferCastDataDescriptor< T > relinquishDataOwnership()
nkMemory::BufferCast::BufferCast
BufferCast() noexcept=default
nkMemory::BufferCast::resize
BufferCast< T > & resize(unsigned long long size)
nkMemory::Buffer
A buffer holding binary data.
Definition: Buffer.h:32
nkMemory::BufferCast::front
T & front()
nkMemory::BufferCast
Holds a Buffer and make it easy to cast the binary data.
Definition: BufferCast.h:18
nkMemory::BufferCast::end
T * end()
nkMemory::BufferCast::erase
BufferCast< T > & erase(unsigned long long index, unsigned long long count=1ull) Buffer relinquishBufferOwnership()
nkMemory::BufferCast::begin
T * begin()
nkMemory
Encompasses all API of component NilkinsMemory.
Definition: Allocator.h:7